import java.util.ArrayList;
import java.util.List;
public class Student {
    private String studentId;
    private String studentName;
    private List<Grade> courseGrades;
    public Student(String studentId, String studentName) {
        this.studentId = studentId;
        this.studentName = studentName;
        this.courseGrades = new ArrayList<>();
    }
    public void addCourseGrade(Grade courseGrade) {
        courseGrades.add(courseGrade);
    }
    public String getStudentId() {
        return studentId;
    }
    public String getStudentName() {
        return studentName;
    }
    public double calculateGPA() {
        double totalGradePoints = 0;
        int totalCredits = 0;
        for (Grade courseGrade : courseGrades) {
            Course course = courseGrade.getCourse();
            double score = courseGrade.getScore();
            double gradePoint = convertScoreToGradePoint(score);
            int credit = course.credit();
            totalGradePoints += gradePoint * credit;
            totalCredits += credit;
        }
        return totalGradePoints / totalCredits;
    }
    private double convertScoreToGradePoint(double score) {
        if (score >= 90) {
            return 4.0;
        } else if (score >= 80) {
            return 3.0;
        } else if (score >= 70) {
            return 2.0;
        } else if (score >= 60) {
            return 1.0;
        }
        return 0.0;
    }
    public List<Grade> getCourseGrades() {
        return courseGrades;
    }
}